Repository navigation
fix(persistence): drop entries whose row is gone instead of failing every later save - #1624
Open
leqatoavgust-dot wants to merge 1 commit into
Open
leqatoavgust-dot wants to merge 1 commit into
leqatoavgust-dot wants to merge 1 commit into
Conversation
…very later save A delete or update of a row which no longer exists (for example an item destroyed by a chaos mix, or a dropped item which expired and was deleted by another context) fails with 'expected to affect 1 row(s), but actually affected 0 row(s)'. The entry stayed in the change tracker, so every retry and every later save of the session failed the same way, and the player's progress was lost at logout. When a save is rejected with a DbUpdateConcurrencyException, the conflicting entries are now checked against the database: an entry in state Deleted or Modified whose row is gone is detached (together with its aggregate members, e.g. an item's option links), and the save is retried (up to 5 attempts instead of 3), so everything else is saved. Fixes MUnique#1478
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened
A save fails with
DbUpdateConcurrencyException("expected to affect 1 row(s), but actually affected 0 row(s)") when it deletes or updates a row which no longer exists: an item destroyed by a chaos mix, or a dropped item which expired and was deleted by another context (both are in #1478). The failing entry stayed in the change tracker, so the bounded retry sent the same statement again three times, and every later save of the session failed the same way. Everything the player did until logout was lost.The change
When a save is rejected with a
DbUpdateConcurrencyException,EntityFrameworkContextBasenow asks the database for each conflicting entry's row:DeletedorModifiedwhose row is gone is detached, together with its aggregate members (e.g. an item's option links, which are gone with it). A delete of such a row is done already; an update of it can never succeed.Entries whose row still exists are left alone, so a real conflict still fails as before. Configuration edits (with their own transaction) are not touched.
How it was tested
/clearinvwas used. The log showed the conflict (Save conflict for "Item" (...), state Deleted), thenDropping "Item" from the save: its row is gone already, and the retry saved the other 38 deleted items. Without the change, all three attempts fail and the session stays unable to save.Fixes #1478
🤖 Generated with Claude Code